<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>XenC: include/kenlm/util/double-conversion/utils.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">XenC
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">Open-source tool for data selection in NLP</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_5417fc49d29c4cfca6bc3f52c9c7deba.html">kenlm</a></li><li class="navelem"><a class="el" href="dir_9ec25de6763e2dc47109730f881b7e3e.html">util</a></li><li class="navelem"><a class="el" href="dir_5fd0dc67f55ed56e6f450361f3921d3b.html">double-conversion</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">utils.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="utils_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">// Copyright 2010 the V8 project authors. All rights reserved.</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">// Redistribution and use in source and binary forms, with or without</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">// modification, are permitted provided that the following conditions are</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">// met:</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">//     * Redistributions of source code must retain the above copyright</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">//       notice, this list of conditions and the following disclaimer.</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">//     * Redistributions in binary form must reproduce the above</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">//       copyright notice, this list of conditions and the following</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">//       disclaimer in the documentation and/or other materials provided</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment">//       with the distribution.</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">//     * Neither the name of Google Inc. nor the names of its</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">//       contributors may be used to endorse or promote products derived</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment">//       from this software without specific prior written permission.</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment">// &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#ifndef DOUBLE_CONVERSION_UTILS_H_</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#define DOUBLE_CONVERSION_UTILS_H_</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &lt;string.h&gt;</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &lt;assert.h&gt;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#ifndef ASSERT</span></div><div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">   36</a></span>&#160;<span class="preprocessor">#define ASSERT(condition)      (assert(condition))</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#ifndef UNIMPLEMENTED</span></div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="utils_8h.html#add09d39ec888c2d7e12877586f29368d">   39</a></span>&#160;<span class="preprocessor">#define UNIMPLEMENTED() (abort())</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#ifndef UNREACHABLE</span></div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="utils_8h.html#ad8fee49eb2770153a2dd95953f9b74e5">   42</a></span>&#160;<span class="preprocessor">#define UNREACHABLE()   (abort())</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="comment">// Double operations detection based on target architecture.</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="comment">// Linux uses a 80bit wide floating point stack on x86. This induces double</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="comment">// rounding, which in turn leads to wrong results.</span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<span class="comment">// An easy way to test if the floating-point operations are correct is to</span></div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="comment">// evaluate: 89255.0/1e22. If the floating-point stack is 64 bits wide then</span></div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="comment">// the result is equal to 89255e-22.</span></div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="comment">// The best way to test this, is to create a division-function and to compare</span></div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="comment">// the output of the division with the expected result. (Inlining must be</span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="comment">// disabled.)</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="comment">// On Linux,x86 89255e-22 != Div_double(89255.0/1e22)</span></div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="preprocessor">#if defined(_M_X64) || defined(__x86_64__) || \</span></div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="preprocessor">    defined(__ARMEL__) || defined(__avr32__) || \</span></div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="preprocessor">    defined(__hppa__) || defined(__ia64__) || \</span></div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;<span class="preprocessor">    defined(__mips__) || defined(__powerpc__) || \</span></div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;<span class="preprocessor">    defined(__sparc__) || defined(__sparc) || defined(__s390__) || \</span></div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<span class="preprocessor">    defined(__SH4__) || defined(__alpha__) || \</span></div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<span class="preprocessor">    defined(_MIPS_ARCH_MIPS32R2)</span></div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;<span class="preprocessor">#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1</span></div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<span class="preprocessor">#elif defined(_M_IX86) || defined(__i386__) || defined(__i386)</span></div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="preprocessor">#if defined(_WIN32)</span></div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="comment">// Windows uses a 64bit wide floating point stack.</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="preprocessor">#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1</span></div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;<span class="preprocessor">#else</span></div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="preprocessor">#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS</span></div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;<span class="preprocessor">#endif  // _WIN32</span></div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="preprocessor">#else</span></div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="preprocessor">#error Target architecture was not detected as supported by Double-Conversion.</span></div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="preprocessor">#if defined(_WIN32) &amp;&amp; !defined(__MINGW32__)</span></div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">char</span> int8_t;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> uint8_t;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">short</span> int16_t;  <span class="comment">// NOLINT</span></div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> uint16_t;  <span class="comment">// NOLINT</span></div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">int</span> int32_t;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> uint32_t;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="keyword">typedef</span> __int64 int64_t;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> __int64 uint64_t;</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="comment">// intptr_t and friends are defined in crtdefs.h through stdio.h.</span></div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="preprocessor">#else</span></div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="preprocessor">#include &lt;stdint.h&gt;</span></div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="comment">// The following macro works on both 32 and 64-bit platforms.</span></div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="comment">// Usage: instead of writing 0x1234567890123456</span></div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="comment">//      write UINT64_2PART_C(0x12345678,90123456);</span></div><div class="line"><a name="l00096"></a><span class="lineno"><a class="line" href="utils_8h.html#af60c14e9c588537ba3fd925be39e29cd">   96</a></span>&#160;<span class="preprocessor">#define UINT64_2PART_C(a, b) (((static_cast&lt;uint64_t&gt;(a) &lt;&lt; 32) + 0x##b##u))</span></div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="comment">// The expression ARRAY_SIZE(a) is a compile-time constant of type</span></div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;<span class="comment">// size_t which represents the number of elements of the given</span></div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="comment">// array. You should only use ARRAY_SIZE on statically allocated</span></div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="comment">// arrays.</span></div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;<span class="preprocessor">#ifndef ARRAY_SIZE</span></div><div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="utils_8h.html#a5f00183ae427b2e71b739a86afaf4d54">  104</a></span>&#160;<span class="preprocessor">#define ARRAY_SIZE(a)                                   \</span></div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="preprocessor">  ((sizeof(a) / sizeof(*(a))) /                         \</span></div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="preprocessor">  static_cast&lt;size_t&gt;(!(sizeof(a) % sizeof(*(a)))))</span></div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;<span class="comment">// A macro to disallow the evil copy constructor and operator= functions</span></div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<span class="comment">// This should be used in the private: declarations for a class</span></div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;<span class="preprocessor">#ifndef DISALLOW_COPY_AND_ASSIGN</span></div><div class="line"><a name="l00112"></a><span class="lineno"><a class="line" href="utils_8h.html#a8a33c52fbcec82e9f80752504cef5ec7">  112</a></span>&#160;<span class="preprocessor">#define DISALLOW_COPY_AND_ASSIGN(TypeName)      \</span></div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;<span class="preprocessor">  TypeName(const TypeName&amp;);                    \</span></div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="preprocessor">  void operator=(const TypeName&amp;)</span></div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;<span class="comment">// A macro to disallow all the implicit constructors, namely the</span></div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;<span class="comment">// default constructor, copy constructor and operator= functions.</span></div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;<span class="comment">// This should be used in the private: declarations for a class</span></div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;<span class="comment">// that wants to prevent anyone from instantiating it. This is</span></div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;<span class="comment">// especially useful for classes containing only static methods.</span></div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;<span class="preprocessor">#ifndef DISALLOW_IMPLICIT_CONSTRUCTORS</span></div><div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="utils_8h.html#acfd97435e2829938f396946b00559b71">  124</a></span>&#160;<span class="preprocessor">#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \</span></div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="preprocessor">  TypeName();                                    \</span></div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;<span class="preprocessor">  DISALLOW_COPY_AND_ASSIGN(TypeName)</span></div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacedouble__conversion.html">double_conversion</a> {</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div><div class="line"><a name="l00131"></a><span class="lineno"><a class="line" href="namespacedouble__conversion.html#a0eb9c6ce32a4965e51a34613bcb4eb2b">  131</a></span>&#160;<span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="namespacedouble__conversion.html#a0eb9c6ce32a4965e51a34613bcb4eb2b">kCharSize</a> = <span class="keyword">sizeof</span>(char);</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;<span class="comment">// Returns the maximum of the two parameters.</span></div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00135"></a><span class="lineno"><a class="line" href="namespacedouble__conversion.html#a8fcbedaa7b8db4ff4c6c37cb52ebb738">  135</a></span>&#160;<span class="keyword">static</span> T <a class="code" href="namespacedouble__conversion.html#a8fcbedaa7b8db4ff4c6c37cb52ebb738">Max</a>(T a, T b) {</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;  <span class="keywordflow">return</span> a &lt; b ? b : a;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;}</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="comment">// Returns the minimum of the two parameters.</span></div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00142"></a><span class="lineno"><a class="line" href="namespacedouble__conversion.html#a94fc7999ec1907245f51992efe70d097">  142</a></span>&#160;<span class="keyword">static</span> T <a class="code" href="namespacedouble__conversion.html#a94fc7999ec1907245f51992efe70d097">Min</a>(T a, T b) {</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  <span class="keywordflow">return</span> a &lt; b ? a : b;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;}</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno"><a class="line" href="namespacedouble__conversion.html#a2773753c702fd8d42f8249990f73cb62">  147</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="namespacedouble__conversion.html#a2773753c702fd8d42f8249990f73cb62">StrLength</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keywordtype">string</span>) {</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;  <span class="keywordtype">size_t</span> length = strlen(<span class="keywordtype">string</span>);</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;  <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(length == static_cast&lt;size_t&gt;(static_cast&lt;int&gt;(length)));</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(length);</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;}</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;<span class="comment">// This is a simplified version of V8&#39;s Vector class.</span></div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00155"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html">  155</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdouble__conversion_1_1_vector.html">Vector</a> {</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00157"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#ac003464ea085dab8d14b3b96d6f5695e">  157</a></span>&#160;  <a class="code" href="classdouble__conversion_1_1_vector.html#ac003464ea085dab8d14b3b96d6f5695e">Vector</a>() : start_(NULL), length_(0) {}</div><div class="line"><a name="l00158"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#a24d9034fc99d567271c41f4481874e8a">  158</a></span>&#160;  <a class="code" href="classdouble__conversion_1_1_vector.html#a24d9034fc99d567271c41f4481874e8a">Vector</a>(T* data, <span class="keywordtype">int</span> <a class="code" href="classdouble__conversion_1_1_vector.html#a63a7065b57ee551499749799b8c51145">length</a>) : start_(data), length_(length) {</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(length == 0 || (length &gt; 0 &amp;&amp; data != NULL));</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;  }</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;  <span class="comment">// Returns a vector using the same backing storage as this one,</span></div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;  <span class="comment">// spanning from and including &#39;from&#39;, to but not including &#39;to&#39;.</span></div><div class="line"><a name="l00164"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#a00b66321470fbd4797801ce130965c05">  164</a></span>&#160;  <a class="code" href="classdouble__conversion_1_1_vector.html">Vector&lt;T&gt;</a> <a class="code" href="classdouble__conversion_1_1_vector.html#a00b66321470fbd4797801ce130965c05">SubVector</a>(<span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to) {</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(to &lt;= length_);</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(from &lt; to);</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(0 &lt;= from);</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="classdouble__conversion_1_1_vector.html">Vector&lt;T&gt;</a>(<a class="code" href="classdouble__conversion_1_1_vector.html#abdd90662ad4779639dc86361c0bf7a98">start</a>() + from, to - from);</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  }</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;  <span class="comment">// Returns the length of the vector.</span></div><div class="line"><a name="l00172"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#a63a7065b57ee551499749799b8c51145">  172</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classdouble__conversion_1_1_vector.html#a63a7065b57ee551499749799b8c51145">length</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> length_; }</div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;  <span class="comment">// Returns whether or not the vector is empty.</span></div><div class="line"><a name="l00175"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#a11e12ca7d892ca92a4fa70b295e4c844">  175</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classdouble__conversion_1_1_vector.html#a11e12ca7d892ca92a4fa70b295e4c844">is_empty</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> length_ == 0; }</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;  <span class="comment">// Returns the pointer to the start of the data in the vector.</span></div><div class="line"><a name="l00178"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#abdd90662ad4779639dc86361c0bf7a98">  178</a></span>&#160;  T* <a class="code" href="classdouble__conversion_1_1_vector.html#abdd90662ad4779639dc86361c0bf7a98">start</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> start_; }</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;  <span class="comment">// Access individual vector elements - checks bounds in debug mode.</span></div><div class="line"><a name="l00181"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#aae9163cbc9fe32b98773108718e5bb89">  181</a></span>&#160;  T&amp; <a class="code" href="classdouble__conversion_1_1_vector.html#aae9163cbc9fe32b98773108718e5bb89">operator[]</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const </span>{</div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(0 &lt;= index &amp;&amp; index &lt; length_);</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    <span class="keywordflow">return</span> start_[index];</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;  }</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;</div><div class="line"><a name="l00186"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#a23d1f6a7e28c139ba390923b7d2af327">  186</a></span>&#160;  T&amp; <a class="code" href="classdouble__conversion_1_1_vector.html#a23d1f6a7e28c139ba390923b7d2af327">first</a>() { <span class="keywordflow">return</span> start_[0]; }</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;</div><div class="line"><a name="l00188"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_vector.html#a7e64ba385ba346ee0afef948256b139f">  188</a></span>&#160;  T&amp; <a class="code" href="classdouble__conversion_1_1_vector.html#a7e64ba385ba346ee0afef948256b139f">last</a>() { <span class="keywordflow">return</span> start_[length_ - 1]; }</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  T* start_;</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;  <span class="keywordtype">int</span> length_;</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;};</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;<span class="comment">// Helper class for building result strings in a character buffer. The</span></div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;<span class="comment">// purpose of the class is to use safe operations that checks the</span></div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;<span class="comment">// buffer bounds on all operations in debug mode.</span></div><div class="line"><a name="l00199"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html">  199</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdouble__conversion_1_1_string_builder.html">StringBuilder</a> {</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00201"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#abc26247c3338c82f19fd04d17dbb6b3b">  201</a></span>&#160;  <a class="code" href="classdouble__conversion_1_1_string_builder.html#abc26247c3338c82f19fd04d17dbb6b3b">StringBuilder</a>(<span class="keywordtype">char</span>* buffer, <span class="keywordtype">int</span> size)</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;      : buffer_(buffer, size), position_(0) { }</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div><div class="line"><a name="l00204"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a42c0814276a6a95508a90cbd48a5b379">  204</a></span>&#160;  <a class="code" href="classdouble__conversion_1_1_string_builder.html#a42c0814276a6a95508a90cbd48a5b379">~StringBuilder</a>() { <span class="keywordflow">if</span> (!is_finalized()) Finalize(); }</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;</div><div class="line"><a name="l00206"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a7ac8e46de105606011adb8812d16e274">  206</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#a7ac8e46de105606011adb8812d16e274">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> buffer_.length(); }</div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;  <span class="comment">// Get the current position in the builder.</span></div><div class="line"><a name="l00209"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#ac8b8087d46c63e4d6cb92948b0ee8943">  209</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#ac8b8087d46c63e4d6cb92948b0ee8943">position</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(!is_finalized());</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="keywordflow">return</span> position_;</div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;  }</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;  <span class="comment">// Reset the position.</span></div><div class="line"><a name="l00215"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a5383d4200be0f361b2d3d49ef4e702f3">  215</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#a5383d4200be0f361b2d3d49ef4e702f3">Reset</a>() { position_ = 0; }</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;  <span class="comment">// Add a single character to the builder. It is not allowed to add</span></div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;  <span class="comment">// 0-characters; use the Finalize() method to terminate the string</span></div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;  <span class="comment">// instead.</span></div><div class="line"><a name="l00220"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a0f0d2f43e9b5ee17fc860e9b34eeb6ab">  220</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#a0f0d2f43e9b5ee17fc860e9b34eeb6ab">AddCharacter</a>(<span class="keywordtype">char</span> c) {</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    <span class="comment">// I just extract raw data not a cstr so null is fine.</span></div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;    <span class="comment">//ASSERT(c != &#39;\0&#39;);</span></div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(!is_finalized() &amp;&amp; position_ &lt; buffer_.length());</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    buffer_[position_++] = c;</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;  }</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;  <span class="comment">// Add an entire string to the builder. Uses strlen() internally to</span></div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;  <span class="comment">// compute the length of the input string.</span></div><div class="line"><a name="l00229"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#ac59d10a9fd15d9bb520c951033fcecc6">  229</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#ac59d10a9fd15d9bb520c951033fcecc6">AddString</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) {</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    AddSubstring(s, <a class="code" href="namespacedouble__conversion.html#a2773753c702fd8d42f8249990f73cb62">StrLength</a>(s));</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;  }</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;  <span class="comment">// Add the first &#39;n&#39; characters of the given string &#39;s&#39; to the</span></div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;  <span class="comment">// builder. The input string must have enough characters.</span></div><div class="line"><a name="l00235"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a0f562ee153bcd85e7a0f349d986d337f">  235</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#a0f562ee153bcd85e7a0f349d986d337f">AddSubstring</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s, <span class="keywordtype">int</span> n) {</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(!is_finalized() &amp;&amp; position_ + n &lt; buffer_.length());</div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;    <span class="comment">// I just extract raw data not a cstr so null is fine.</span></div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;    <span class="comment">//ASSERT(static_cast&lt;size_t&gt;(n) &lt;= strlen(s));</span></div><div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;    memmove(&amp;buffer_[position_], s, n * kCharSize);</div><div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;    position_ += n;</div><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;  }</div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;  <span class="comment">// Add character padding to the builder. If count is non-positive,</span></div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;  <span class="comment">// nothing is added to the builder.</span></div><div class="line"><a name="l00246"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a855bb1504ecce09e8b3c2d90487f9164">  246</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classdouble__conversion_1_1_string_builder.html#a855bb1504ecce09e8b3c2d90487f9164">AddPadding</a>(<span class="keywordtype">char</span> c, <span class="keywordtype">int</span> count) {</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; count; i++) {</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;      AddCharacter(c);</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;    }</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;  }</div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;  <span class="comment">// Finalize the string by 0-terminating it and returning the buffer.</span></div><div class="line"><a name="l00253"></a><span class="lineno"><a class="line" href="classdouble__conversion_1_1_string_builder.html#a0ad85d938ba7b7a9739cd605b85a3eef">  253</a></span>&#160;  <span class="keywordtype">char</span>* <a class="code" href="classdouble__conversion_1_1_string_builder.html#a0ad85d938ba7b7a9739cd605b85a3eef">Finalize</a>() {</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(!is_finalized() &amp;&amp; position_ &lt; buffer_.length());</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;    buffer_[position_] = <span class="charliteral">&#39;\0&#39;</span>;</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;    <span class="comment">// Make sure nobody managed to add a 0-character to the</span></div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;    <span class="comment">// buffer while building the string.</span></div><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    <span class="comment">// I just extract raw data not a cstr so null is fine.</span></div><div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    <span class="comment">//ASSERT(strlen(buffer_.start()) == static_cast&lt;size_t&gt;(position_));</span></div><div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    position_ = -1;</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    <a class="code" href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a>(is_finalized());</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;    <span class="keywordflow">return</span> buffer_.start();</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;  }</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;  <a class="code" href="classdouble__conversion_1_1_vector.html">Vector&lt;char&gt;</a> buffer_;</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;  <span class="keywordtype">int</span> position_;</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;  <span class="keywordtype">bool</span> is_finalized()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> position_ &lt; 0; }</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;</div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;  <a class="code" href="utils_8h.html#acfd97435e2829938f396946b00559b71">DISALLOW_IMPLICIT_CONSTRUCTORS</a>(<a class="code" href="classdouble__conversion_1_1_string_builder.html">StringBuilder</a>);</div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;};</div><div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;</div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;<span class="comment">// The type-based aliasing rule allows the compiler to assume that pointers of</span></div><div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;<span class="comment">// different types (for some definition of different) never alias each other.</span></div><div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;<span class="comment">// Thus the following code does not work:</span></div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;<span class="comment">// float f = foo();</span></div><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;<span class="comment">// int fbits = *(int*)(&amp;f);</span></div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;<span class="comment">// The compiler &#39;knows&#39; that the int pointer can&#39;t refer to f since the types</span></div><div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;<span class="comment">// don&#39;t match, so the compiler may cache f in a register, leaving random data</span></div><div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;<span class="comment">// in fbits.  Using C++ style casts makes no difference, however a pointer to</span></div><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;<span class="comment">// char data is assumed to alias any other pointer.  This is the &#39;memcpy</span></div><div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;<span class="comment">// exception&#39;.</span></div><div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;<span class="comment">// Bit_cast uses the memcpy exception to move the bits from a variable of one</span></div><div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;<span class="comment">// type of a variable of another type.  Of course the end result is likely to</span></div><div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;<span class="comment">// be implementation dependent.  Most compilers (gcc-4.2 and MSVC 2005)</span></div><div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;<span class="comment">// will completely optimize BitCast away.</span></div><div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;<span class="comment">// There is an additional use for BitCast.</span></div><div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;<span class="comment">// Recent gccs will warn when they see casts that may result in breakage due to</span></div><div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;<span class="comment">// the type-based aliasing rule.  If you have checked that there is no breakage</span></div><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;<span class="comment">// you can use BitCast to cast one pointer type to another.  This confuses gcc</span></div><div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;<span class="comment">// enough that it can no longer see that you have cast one pointer type to</span></div><div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;<span class="comment">// another thus avoiding the warning.</span></div><div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">class</span> Dest, <span class="keyword">class</span> Source&gt;</div><div class="line"><a name="l00299"></a><span class="lineno"><a class="line" href="namespacedouble__conversion.html#a18244d6d2e60e0f097fabae206477963">  299</a></span>&#160;<span class="keyword">inline</span> Dest <a class="code" href="namespacedouble__conversion.html#a18244d6d2e60e0f097fabae206477963">BitCast</a>(<span class="keyword">const</span> Source&amp; source) {</div><div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;  <span class="comment">// Compile time assertion: sizeof(Dest) == sizeof(Source)</span></div><div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;  <span class="comment">// A compile error here means your Dest and Source have different sizes.</span></div><div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;  <span class="keyword">typedef</span> <span class="keywordtype">char</span> VerifySizesAreEqual[<span class="keyword">sizeof</span>(Dest) == <span class="keyword">sizeof</span>(Source) ? 1 : -1]</div><div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;<span class="preprocessor">#if __GNUC__ &gt; 4 || __GNUC__ == 4 &amp;&amp; __GNUC_MINOR__ &gt;= 8</span></div><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;      __attribute__((unused))</div><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;      ;</div><div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;</div><div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;  Dest dest;</div><div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;  memmove(&amp;dest, &amp;source, <span class="keyword">sizeof</span>(dest));</div><div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;  <span class="keywordflow">return</span> dest;</div><div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;}</div><div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;</div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">class</span> Dest, <span class="keyword">class</span> Source&gt;</div><div class="line"><a name="l00314"></a><span class="lineno"><a class="line" href="namespacedouble__conversion.html#a240fadea2eaf5a7d52d766d8b424427a">  314</a></span>&#160;<span class="keyword">inline</span> Dest <a class="code" href="namespacedouble__conversion.html#a18244d6d2e60e0f097fabae206477963">BitCast</a>(Source* source) {</div><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;  <span class="keywordflow">return</span> BitCast&lt;Dest&gt;(<span class="keyword">reinterpret_cast&lt;</span>uintptr_t<span class="keyword">&gt;</span>(source));</div><div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;}</div><div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;</div><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;}  <span class="comment">// namespace double_conversion</span></div><div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;</div><div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;<span class="preprocessor">#endif  // DOUBLE_CONVERSION_UTILS_H_</span></div><div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a855bb1504ecce09e8b3c2d90487f9164"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a855bb1504ecce09e8b3c2d90487f9164">double_conversion::StringBuilder::AddPadding</a></div><div class="ttdeci">void AddPadding(char c, int count)</div><div class="ttdef"><b>Definition:</b> utils.h:246</div></div>
<div class="ttc" id="utils_8h_html_acfd97435e2829938f396946b00559b71"><div class="ttname"><a href="utils_8h.html#acfd97435e2829938f396946b00559b71">DISALLOW_IMPLICIT_CONSTRUCTORS</a></div><div class="ttdeci">#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)</div><div class="ttdef"><b>Definition:</b> utils.h:124</div></div>
<div class="ttc" id="utils_8h_html_a1dfb2cb545fa51edb2760047aa4ce45f"><div class="ttname"><a href="utils_8h.html#a1dfb2cb545fa51edb2760047aa4ce45f">ASSERT</a></div><div class="ttdeci">#define ASSERT(condition)        </div><div class="ttdef"><b>Definition:</b> utils.h:36</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_a63a7065b57ee551499749799b8c51145"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#a63a7065b57ee551499749799b8c51145">double_conversion::Vector::length</a></div><div class="ttdeci">int length() const </div><div class="ttdef"><b>Definition:</b> utils.h:172</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_a7e64ba385ba346ee0afef948256b139f"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#a7e64ba385ba346ee0afef948256b139f">double_conversion::Vector::last</a></div><div class="ttdeci">T &amp; last()</div><div class="ttdef"><b>Definition:</b> utils.h:188</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_ac59d10a9fd15d9bb520c951033fcecc6"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#ac59d10a9fd15d9bb520c951033fcecc6">double_conversion::StringBuilder::AddString</a></div><div class="ttdeci">void AddString(const char *s)</div><div class="ttdef"><b>Definition:</b> utils.h:229</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a42c0814276a6a95508a90cbd48a5b379"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a42c0814276a6a95508a90cbd48a5b379">double_conversion::StringBuilder::~StringBuilder</a></div><div class="ttdeci">~StringBuilder()</div><div class="ttdef"><b>Definition:</b> utils.h:204</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_a11e12ca7d892ca92a4fa70b295e4c844"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#a11e12ca7d892ca92a4fa70b295e4c844">double_conversion::Vector::is_empty</a></div><div class="ttdeci">bool is_empty() const </div><div class="ttdef"><b>Definition:</b> utils.h:175</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html">double_conversion::Vector</a></div><div class="ttdef"><b>Definition:</b> utils.h:155</div></div>
<div class="ttc" id="namespacedouble__conversion_html_a2773753c702fd8d42f8249990f73cb62"><div class="ttname"><a href="namespacedouble__conversion.html#a2773753c702fd8d42f8249990f73cb62">double_conversion::StrLength</a></div><div class="ttdeci">int StrLength(const char *string)</div><div class="ttdef"><b>Definition:</b> utils.h:147</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html">double_conversion::StringBuilder</a></div><div class="ttdef"><b>Definition:</b> utils.h:199</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_abdd90662ad4779639dc86361c0bf7a98"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#abdd90662ad4779639dc86361c0bf7a98">double_conversion::Vector::start</a></div><div class="ttdeci">T * start() const </div><div class="ttdef"><b>Definition:</b> utils.h:178</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a0f0d2f43e9b5ee17fc860e9b34eeb6ab"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a0f0d2f43e9b5ee17fc860e9b34eeb6ab">double_conversion::StringBuilder::AddCharacter</a></div><div class="ttdeci">void AddCharacter(char c)</div><div class="ttdef"><b>Definition:</b> utils.h:220</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a0ad85d938ba7b7a9739cd605b85a3eef"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a0ad85d938ba7b7a9739cd605b85a3eef">double_conversion::StringBuilder::Finalize</a></div><div class="ttdeci">char * Finalize()</div><div class="ttdef"><b>Definition:</b> utils.h:253</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a5383d4200be0f361b2d3d49ef4e702f3"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a5383d4200be0f361b2d3d49ef4e702f3">double_conversion::StringBuilder::Reset</a></div><div class="ttdeci">void Reset()</div><div class="ttdef"><b>Definition:</b> utils.h:215</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_abc26247c3338c82f19fd04d17dbb6b3b"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#abc26247c3338c82f19fd04d17dbb6b3b">double_conversion::StringBuilder::StringBuilder</a></div><div class="ttdeci">StringBuilder(char *buffer, int size)</div><div class="ttdef"><b>Definition:</b> utils.h:201</div></div>
<div class="ttc" id="namespacedouble__conversion_html_a0eb9c6ce32a4965e51a34613bcb4eb2b"><div class="ttname"><a href="namespacedouble__conversion.html#a0eb9c6ce32a4965e51a34613bcb4eb2b">double_conversion::kCharSize</a></div><div class="ttdeci">static const int kCharSize</div><div class="ttdef"><b>Definition:</b> utils.h:131</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a7ac8e46de105606011adb8812d16e274"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a7ac8e46de105606011adb8812d16e274">double_conversion::StringBuilder::size</a></div><div class="ttdeci">int size() const </div><div class="ttdef"><b>Definition:</b> utils.h:206</div></div>
<div class="ttc" id="namespacedouble__conversion_html_a94fc7999ec1907245f51992efe70d097"><div class="ttname"><a href="namespacedouble__conversion.html#a94fc7999ec1907245f51992efe70d097">double_conversion::Min</a></div><div class="ttdeci">static T Min(T a, T b)</div><div class="ttdef"><b>Definition:</b> utils.h:142</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_aae9163cbc9fe32b98773108718e5bb89"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#aae9163cbc9fe32b98773108718e5bb89">double_conversion::Vector::operator[]</a></div><div class="ttdeci">T &amp; operator[](int index) const </div><div class="ttdef"><b>Definition:</b> utils.h:181</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_a0f562ee153bcd85e7a0f349d986d337f"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#a0f562ee153bcd85e7a0f349d986d337f">double_conversion::StringBuilder::AddSubstring</a></div><div class="ttdeci">void AddSubstring(const char *s, int n)</div><div class="ttdef"><b>Definition:</b> utils.h:235</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_a23d1f6a7e28c139ba390923b7d2af327"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#a23d1f6a7e28c139ba390923b7d2af327">double_conversion::Vector::first</a></div><div class="ttdeci">T &amp; first()</div><div class="ttdef"><b>Definition:</b> utils.h:186</div></div>
<div class="ttc" id="namespacedouble__conversion_html"><div class="ttname"><a href="namespacedouble__conversion.html">double_conversion</a></div><div class="ttdef"><b>Definition:</b> bignum-dtoa.h:33</div></div>
<div class="ttc" id="namespacedouble__conversion_html_a8fcbedaa7b8db4ff4c6c37cb52ebb738"><div class="ttname"><a href="namespacedouble__conversion.html#a8fcbedaa7b8db4ff4c6c37cb52ebb738">double_conversion::Max</a></div><div class="ttdeci">static T Max(T a, T b)</div><div class="ttdef"><b>Definition:</b> utils.h:135</div></div>
<div class="ttc" id="classdouble__conversion_1_1_string_builder_html_ac8b8087d46c63e4d6cb92948b0ee8943"><div class="ttname"><a href="classdouble__conversion_1_1_string_builder.html#ac8b8087d46c63e4d6cb92948b0ee8943">double_conversion::StringBuilder::position</a></div><div class="ttdeci">int position() const </div><div class="ttdef"><b>Definition:</b> utils.h:209</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_a00b66321470fbd4797801ce130965c05"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#a00b66321470fbd4797801ce130965c05">double_conversion::Vector::SubVector</a></div><div class="ttdeci">Vector&lt; T &gt; SubVector(int from, int to)</div><div class="ttdef"><b>Definition:</b> utils.h:164</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_ac003464ea085dab8d14b3b96d6f5695e"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#ac003464ea085dab8d14b3b96d6f5695e">double_conversion::Vector::Vector</a></div><div class="ttdeci">Vector()</div><div class="ttdef"><b>Definition:</b> utils.h:157</div></div>
<div class="ttc" id="namespacedouble__conversion_html_a18244d6d2e60e0f097fabae206477963"><div class="ttname"><a href="namespacedouble__conversion.html#a18244d6d2e60e0f097fabae206477963">double_conversion::BitCast</a></div><div class="ttdeci">Dest BitCast(const Source &amp;source)</div><div class="ttdef"><b>Definition:</b> utils.h:299</div></div>
<div class="ttc" id="classdouble__conversion_1_1_vector_html_a24d9034fc99d567271c41f4481874e8a"><div class="ttname"><a href="classdouble__conversion_1_1_vector.html#a24d9034fc99d567271c41f4481874e8a">double_conversion::Vector::Vector</a></div><div class="ttdeci">Vector(T *data, int length)</div><div class="ttdef"><b>Definition:</b> utils.h:158</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 18 2016 17:22:37 for XenC by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
